package com.cwvs.cat.adapter;

import java.util.List;

import net.tsz.afinal.FinalBitmap;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.cwvs.cat.R;
import com.cwvs.cat.bean.ActiveContent;
import com.cwvs.cat.net.Port;

public class SchoolMateInviteActiveAdapter extends BaseAdapter {

	private LayoutInflater mInflater = null;
	private ViewHolder holder = null;
	private List<ActiveContent> mList;
	private FinalBitmap fb;
	public SchoolMateInviteActiveAdapter(Context context, List<ActiveContent> list){
		this.mInflater = LayoutInflater.from(context);
		mList = list;
		fb =FinalBitmap.create(context);
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.item_list_school_mate_invite_active, null);
			holder = new ViewHolder();
			holder.title1 = (TextView) convertView.findViewById(R.id.title_1);
			holder.address = (TextView) convertView.findViewById(R.id.address);
			holder.time = (TextView) convertView.findViewById(R.id.time);
			holder.image = (ImageView) convertView.findViewById(R.id.image);
			
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		fb.display(holder.image,Port.getImg+mList.get(position).pic);
		holder.title1.setText(mList.get(position).categoryname);
		holder.address.setText(mList.get(position).location);
		holder.time.setText(mList.get(position).created);

		return convertView;
	}
	
	static class ViewHolder{
        public TextView title1,address,time;
        ImageView image;
    }

}
